package com.yytek.nmp.api;

import com.yytek.common.core.constant.ServiceNameConstants;
import com.yytek.common.core.domain.R;
import com.yytek.nmp.api.domain.UpgradeFirmware;
import com.yytek.nmp.api.domain.UpgradeHistory;
import com.yytek.nmp.api.domain.UpgradeStrategy;
import com.yytek.nmp.api.domain.UpgradeStrategyDeviceTopo;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 设备升级业务相关
 */
@FeignClient(contextId = "remoteUpgradeService", value = ServiceNameConstants.UPGRADE_SERVICE)
public interface RemoteUpgradeService {

    /**
     * 根据策略id获取升级策略绑定设备列表
     * @param id 策略id
     * @return
     */
    @GetMapping("/topo/getBindDeviceTopo")
    R<List<UpgradeStrategyDeviceTopo>> getBindDeviceTopo(@RequestParam("id") Long id);

    /**
     * 获取升级策略信息
     * @param id 策略id
     * @return
     */
    @PostMapping("/strategy/getUpgradeStrategy")
    R<UpgradeStrategy> getUpgradeStrategy(@RequestParam("id") Long id);

    /**
     * 根据策略id获取升级包信息
     * @param id 策略id
     * @return
     */
    @PostMapping("/strategy/getUpgradeFileByStrategyId")
    R<UpgradeFirmware> getUpgradeFileByStrategyId(@RequestParam("id") Long id);

    /**
     * 添加保存升级记录
     * @param upgradeHistory
     * @return
     */
    @PutMapping("/history/addUpgradeHistory")
    R addUpgradeHistory(@RequestBody UpgradeHistory upgradeHistory);

    /**
     * 更新设备升级记录状态
     * @param iotId
     * @param upgradeStrategyId
     * @param status
     * @return
     */
    @PostMapping("/history/changeStrategyHisStatus")
    R changeStrategyHisStatus(@RequestParam("iotId") String iotId, @RequestParam("upgradeStrategyId") Long upgradeStrategyId,
                              @RequestParam("status") int status);

    /**
     * 根据设备id和执行状态查询升级记录
     * @param iotId
     * @param status
     * @return
     */
    @PostMapping("/history/selectUpgradeHisByIotId")
    R<List<UpgradeHistory>> selectUpgradeHisByIotId(@RequestParam("iotId")String iotId,
                                                 @RequestParam("status")int status);
}
